<?php

namespace app\api\controller;

use app\common\controller\Api;
use fast\Yongyou;
use addons\faqueue\library\QueueApi;
use think\Db;

/**
 * 首页接口
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 首页
     *
     */
    public function index()
    {

       Yongyou::addOrder2(146);
    }

     public function info()
    {

        $post = $this->request->request();
       
        if (empty($post['ids'])) {
             $this->error('请选择商品');
        }



        $Litestoregoodsspec = new \app\admin\model\litestore\Litestoregoodsspec;
        $map['fa_litestore_goods_spec.goods_spec_id'] = ['in',explode(',', $post['ids'])];
        

        $list = $Litestoregoodsspec
                    ->with(['good'])
                    ->where($map)
                    ->order('fa_litestore_goods_spec.goods_spec_id desc')
                    ->select();

        foreach ($list as $key => $value) {
            if (empty($value['spec_name'])) {
                $list[$key]['spec_name'] = '';
            }
        }

        $this->success('请求成功',$list);
    }

    /**
     * 首页
     *
     */
    public function closeOrder()
    {


        $map['expiretime'] = ['<=',time()];
        $map['orderstate'] = 0;
        $updata['orderstate'] = 4;
        $num = Db::table('fa_pifa_order')->where($map)->update($updata);


        $this->success('请求成功',$num);
    }

    /**
     * 首页
     *
     */
    public function TongbuOrder()
    {


   
        $map['paystate'] = 1;
        $map['shanghu_status'] = '0';
      
        $list = Db::table('fa_pifa_order')->where($map)->select();

        foreach ($list as $key => $value) {
           QueueApi::push('addons\faqueue\library\jobs\OrderTongbu',$value['id'],'order');
        }


        $this->success('请求成功',count($list));
    }
}
